package com.gpipe.tools;

import com.google.gson.JsonArray;
import com.google.gson.JsonParser;

public class Point {
	public Double y;//纬度
	public Double x;//经度
	
	
	public void setPoint(Double longitude,Double latitude) {
		this.y = latitude;
		this.x = longitude;
	}
	public void setPoint(String str) {
		JsonParser parser = new JsonParser(); // 创建JSON解析器
		JsonArray array = (JsonArray) parser.parse(str);
		if(array.size()==2) {
			this.x = Double.parseDouble(array.get(0).toString());
			this.y = Double.parseDouble(array.get(1).toString());
		}else {
			System.out.println("point in fail");
		}
		
	}
	
	public Double getLatitude() {
		return y;
	}
	public void setLatitude(Double latitude) {
		this.y = latitude;
	}
	public Double getLongitude() {
		return x;
	}
	public void setLongitude(Double longitude) {
		this.x = longitude;
	}
	public String print() {
		return this.x.toString()+"|"+this.y.toString();
	}
}
